#!/bin/bash

SQOOP_HOME=/usr/bin/sqoop
if [[ $1 == "" ]];then
   TD_DATE=`date -d '1 days ago' "+%Y-%m-%d"`
else
   TD_DATE=$1
fi


/usr/bin/sqoop import \
--connect jdbc:mysql://106.75.33.59:3306/nev \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select id, create_date_time, session_id, sid, create_time, seo_source, seo_keywords, ip, area, country, province, city, origin_channel, user as user_match, manual_time, begin_time, end_time, last_customer_msg_time_stamp, last_agent_msg_time_stamp, reply_msg_count, msg_count, browser_name, os_info, '${TD_DATE}' as dt from web_chat_ems_2019_07 where \$CONDITIONS" \
--hcatalog-database notp_ods \
--hcatalog-table web_chat_ems_2019_07 \
-m 100 \
--split-by id
wait


/usr/bin/sqoop import \
--connect jdbc:mysql://106.75.33.59:3306/nev \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select id,referrer,from_url,landing_page_url,url_title,platform_description,other_params,history, '${TD_DATE}' as dt from web_chat_text_ems_2019_07 where \$CONDITIONS" \
--hcatalog-database notp_ods \
--hcatalog-table web_chat_text_ems_2019_07 \
-m 100 \
--split-by id
wait
